#include "gd32e23x.h"
#include <stdio.h>
#include "systick.h"
#include "gd32e23x_it.h"

#include "bsp.h"
#include <string.h>
#include "lt9211.h"

const char LCM[] = "YTC800WLAK-01-100C";
const char IC[] = "ILI9881C";
const char PANEL[] = "TV080WXQ-N88";

SP sp_ILI9881C = {0, 0, 0, 0};

#include "ei2c.h"
#include "lt9211.h"




int main(void)
{
	bsp_initial();
	delay_1ms(200);

	printf("App Start\r\n");
	printf("LCM:\t%s\r\n", LCM);
	printf("IC:\t%s\r\n", IC);
	printf("PANEL:\t%s\r\n", PANEL);

	ei2c_init();

	bsp_gpio_write_lt9211_rst(1);
	bsp_gpio_write_driver_rst(1);
	delay_1ms(10);

	bsp_gpio_write_lt9211_rst(0);
	bsp_gpio_write_driver_rst(0);
	delay_1ms(25);

	bsp_gpio_write_lt9211_rst(1);
	bsp_gpio_write_driver_rst(1);
	delay_1ms(50);

	LT9211_LVDS2MIPIDSI_Config();

	while (1) {
		printf("loop...\r\n");
		delay_1ms(2000);
	}

	return 0;
}

int _write(int fd, char *ptr, int len)  
{  
	for (int i = 0; i < len; i++)
	{
		usart_data_transmit(USART1, ptr[i]);
		while (RESET == usart_flag_get(USART1, USART_FLAG_TBE));
	}
	return len;
}
